home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / D-G / DinkClass Shareware Package / DinkClass / DDocument.h < prev    next >
Encoding:
Text File  |  1992-12-31  |  4.5 KB  |  163 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        DDocument.h
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Mark Gross
  7.  
  8.     Copyright:    © 1992 by Applied Technical Software, all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <4>    12/31/92    MTG        making the code conditionaly compiled so         that I am
  13.                                     always working with a current         version in either think c
  14.                                     or MPW C++
  15.          <3>    11/14/92    MTG        Bringing the C++ version up to date WRT the ThinkC version.
  16.          <2>      8/9/92    MTG        merging in changes from the think C version
  17.  
  18.     To Do:
  19. */
  20.  
  21.  
  22. // This is the Class declatation for the DDocument class
  23. #ifndef __DDOCUMENT__
  24. #define __DDOCUMENT__
  25.  
  26. #include "DListStuff.h"
  27. #include "DWindow.h"
  28.  
  29. #ifdef THINK_C
  30.     //nothing, its already included in macincludes
  31. #else
  32.     // for MPW
  33.     #include <StandardFile.h>
  34. #endif
  35.  
  36. class DEventHandler;
  37.  
  38. class DDocument : public DEventHandler
  39. {
  40. protected:
  41.     
  42.     Handle    fDataHandle;
  43.         // a place to store data (or not, I tend not to use it)
  44.         
  45.     OSType    fCreator;
  46.     OSType    fFileType;
  47.         // The types of the existing file associated with this 
  48.         // document.  They may be redundent, but for now, thats ok
  49.                         
  50.     Boolean fKMNxtCalledFromWindow;
  51.         // flag indicating when the document's KillMeNext method gets
  52.         // called as a result of the document's window killing itself.                    
  53. public:
  54.  
  55.     StandardFileReply *fFileReply;
  56.         // the FSSpectPtr used for system 7 savyness.
  57.  
  58.     short fFileRef;
  59.         // to keep around if document needs to do a lot of I/O
  60.         // otherwise it would be just as good to "get" the refNum
  61.         // in a local variable each time I/O is done.  Its also
  62.         // used as a flag to indicate that a save as is needed
  63.         // this is so when mFileRef == 0
  64.  
  65.     DWindow *fDWindow;
  66.         // refrence to the window rendering the data within the 
  67.         // document.  It is used in support of the close document
  68.         // flow.
  69.         
  70.     Boolean    fNeedToSave;
  71.         // Not much to say about this one. Set it TRUE if data to in 
  72.         // document has been changed.
  73.         
  74.     DDocument(void);
  75.             // Default constructor, sets simple member vars to NULL.
  76.     
  77.     ~DDocument(void);
  78.             // Default Destructor, Makes shure that the File is closed
  79.             // and alocated memery is freed.
  80.         
  81.     virtual     DDocument* Init( Boolean OpenFromFile);
  82.             // initialize the object if OpenFromFile is TRUE then
  83.             // go through the standardgetfile sequence, otherwise
  84.             // open up a blank document.
  85.  
  86.     virtual void     AEInitDoc(FSSpec *theFSS);
  87.             // initialize the object Open the file then
  88.             // set up the file related members of DDocument.
  89.  
  90.     virtual     Boolean DoSaveAs(void);
  91.             // Closes file if open and uses sfputfile 
  92.             // to locate and open a new file frow writting too
  93.             
  94.     virtual DWindow*     MakeWindow(Boolean hasColorWindows);
  95.             // makes whatever window needed, if computer has color
  96.             // support then creat color quickdraw windows, otherwise 
  97.             // make the old style windows.
  98.  
  99.     virtual Boolean WindowClosed(DWindow *deadWindow);
  100.             // the fDwindow calls this when it gets closed
  101.             // its intended to develope to support multi-window
  102.             // documents in a manner similare to the Eventhandler
  103.             // stuff in the DApplication class
  104.             
  105. protected:
  106.  
  107.     virtual Boolean KillMeNext(void);
  108.         // Do LOTs of house keeping in association with Close
  109.         // and WindowClosed
  110.         
  111.     short WantToSave(WindowPtr theWindow);
  112.         // Pull up that standard dialog withe the window title
  113.         // or something in it.
  114.     
  115. public:
  116.                     
  117.     virtual void HandleMenuChoice(short menuID, short menuItem);            
  118.     virtual void SetUpMenues(void);
  119.  
  120. protected:
  121.  
  122.     virtual void DoUndo(void);
  123.     virtual void DoPaste(void);
  124.     virtual void DoCopy(void);
  125.     virtual void DoClear(void);
  126.     virtual void DoCut(void);
  127.     virtual void DoSellectAll(void);
  128.  
  129.      void             SellectFile(StandardFileReply* reply);
  130.          // Dose the standard ui get file stuff Supports
  131.          // opening existing files in the Init method
  132.          
  133.     Boolean         OpenFile(FSSpec *fileSpec);
  134.         // opens the file, calls ReadData, and sets fRefNum
  135.         // if its approperate.  This gets called from the Init
  136.         // method if OpenExistingFile is true.
  137.         
  138.     virtual OSErr    ReadData(short refNum, long *size);
  139.         // reads the data and places the data wherever its
  140.         // suposed to go.  Should be over ridden to place any
  141.         // application spacific data in the correct place, and 
  142.         // do any filtering or processing to get the data in a
  143.         // good format.
  144.         
  145.     Boolean         SaveFile(void);
  146.         // Save the file in place over the existing file
  147.         // or if fRefNum do the normal save prosses
  148.         
  149.     virtual OSErr     WriteData(short refNum);
  150.         // Writes data to file, big da!
  151.             
  152. };// end of class declaration for DDocument
  153.  
  154.  
  155. #define rWantToSave    500
  156. #define    iYes    1
  157. #define    iNo        3
  158. #define    iCancel    2
  159.  
  160.  
  161.  
  162. #endif __DDOCUMENT__
  163.